/**
 * qq动态表情指令
 */
define(function (require, exports, module) {
    var angular = require('angular');

    var module = angular.module('direcitves.emotion',[]);

    module.directive('emotion',function(){
        return {
            restrict: "A",
            replace: true,
            scope : {
                emotionShow : '=emotion',
                content : '='
            },
            templateUrl: 'js/directives/emotion/emotion.html',
            link: function (scope, element, attr, ctl) {
                $(element).find('.emotions .emotions_item')
                    .on('mouseenter', function(){
                        scope.previewEmotionSrc = $(this).find('.js_emotion_i').data('gifurl');
                        scope.$apply();
                    })
                    .on('click', function(){
                        var $i = $(this).find('.js_emotion_i');
                        var img = '<img src="'+$i.data('gifurl')+'" alt="'+$i.data('title')+'"/>';
                        scope.content += img;
                        scope.emotionShow=!scope.emotionShow;
                        scope.$apply();
                    });
            }
        }
    })
})